<template>
  <div id="updateDialog">
    <el-dialog class="box" title="调试" :visible.sync="updateDialogShow" :before-close="handleClose">
      <div class="headerList">
        <div class="btnList">
          <el-button type="primary"><img :src="starts" class="imgicon"/>启动</el-button>
          <el-button type="primary" style="background-color: #D05133; border-color: #D05133"><img :src="starts" class="imgicon"/>停止</el-button>
          <el-button type="primary" style="background-color: #333B3D; border-color: #333B3D"><img :src="del" class="imgicon"/>删除</el-button>
        </div>
      </div>
      <div class="content">
        <el-table
          :data="projectData"
          border
          stripe border fit highlight-current-row
          style="width: 100%;height:330px; "
          :header-cell-style="{background:'#D8DEE8',height: '20px',padding:'5px 0px'}"
          height="330px"
        >
          <el-table-column
            v-for="(column, index) in cols"
            :prop="column.prop"
            :label="column.label"
            :key="index"
            :width="column.width"
            :sortable="column.sortable"
          >
          </el-table-column>


        </el-table>
        <div class="pagination-container footerPage">
          <el-pagination
            @current-change="CurrentChange"
            @size-change="SizeChange"
            :page-sizes="[5, 10, 20, 50]"
            background layout="total, sizes, prev, pager, next"
            :total="total">
          </el-pagination>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import axios from 'axios'
  import starts from '@/assets/components/start.png'
  import del from '@/assets/components/delete.png'
  export default {
    components: {
    },
    data() {
      return {
        starts,
        del,
        updateDialogFalse: false,
        isIndeterminate: true,
        tabStatus: '1', // tabStatus为 1 时显示设备列表， 为 2 时显示测点列表
        projectData: [],
        total: 0,
        cols: [
          { prop: 'pid', label: '时间', width: '190px', sortable: true },
          { prop: 'name', label: '发送', width: '200px', sortable: true },
          { prop: 'type', label: '接受' }
        ],
        // 数据
        projectdata: {
          access_token: localStorage.getItem('access_token'),
          type: 'object_condition',
          pid: 'ZD201809000001',
          data: {
            condition: {
              gid: '',
              cid: '',
              name: '',
              brand: '',
              catagory: '',
              param: '',
              type: '',
              addr: '',
              attris_file: ''
            },
            page: {
              page_size: '10',
              page_number: '1'
            }
          }
        }
      }
    },
    created() {
      this.updateDialogShow = true
    },
    methods: {
      // 获取总览
      engineData() {
        this.projectdata.pid = this.projectPid
        this.projectdata.data.condition.gid = this.projectGid
        // this.projectdata.data.condition.name = this.projectName
        axios.post('/project', this.projectdata, {
          headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
          }
        }).then((res) => {
          console.log(res)
          this.projectData = res.data.data.items
          this.total = parseInt(res.data.data.page.total)
        })
          .catch(function(error) {
            console.log(error)
          })
      },
      // 当前页
      CurrentChange(val) {
        this.projectdata.data.page.page_number = (val) + ''
        this.engineData()
      },
      // 每页显示多少条
      SizeChange(pageSize) {
        this.projectdata.data.page.page_size = (pageSize) + ''
        this.engineData()
      },
      handleCheckAllChange(val) {
        this.isIndeterminate = false
      },
      handleCheckedCitiesChange(value) {
        const checkedCount = value.length
        this.checkAll = checkedCount === this.details.length
        this.isIndeterminate = checkedCount > 0 && checkedCount < this.details.length
      },
      // 子组件传值
      handleClose() {
        const dialogShow = this.updateDialogFalse // 所需要传的值
        this.$emit('giveFalse', dialogShow) // 传值的参数
        console.log(dialogShow)
      }
    }
  }
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .headerList{
    width: 720px;
    height: 50px;
    background-color: #F0F3F5;
    margin-left: 5px;
    line-height: 50px;
    .imgicon{
      vertical-align: middle;
      padding-right: 5px;
    }
    .btnList{
      width: 248px;
      height: 50px;
      float: right;
    }
    /deep/ .el-button{
      padding: 7px 9px;
    }
  }
  .content{
    width: 720px;
    height: 350px;
    margin-left: 5px;
    .footerPage{
      float: right;
      right:20px;
      position: relative;
    }
  }
  /*****************第一层弹窗*****************/
  .testColor{
    padding: 0;
    color: #fff;
  }
  .foorterLeft{
    width: 100px;
    height: 20px;
    font-size:14px;
    font-family:MicrosoftYaHei;
    font-weight:400;
    color:rgba(105,114,126,1);
    float: left;
  }
  /*****************第一层弹窗*****************/
  /deep/ .box > .el-dialog{
    width: 750px;
    height: 500px;
    margin-top: 30vh !important;
    border-radius: 4px;
  }
  /*****************第一层弹窗头部*****************/
  /deep/ .box > .el-dialog > .el-dialog__header{
    width: 750px;
    height: 39px;
    line-height: 43px;
    padding: 0;
    text-indent: 20px;
    font-weight: bolder;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    background-color: #e3e6ee;
  }
  /deep/ .box > .el-dialog > .el-dialog__header > .el-dialog__headerbtn{
    top: 12px;
  }
  /deep/ .box > .el-dialog > .el-dialog__header > .el-dialog__headerbtn > i{
    font-size: 18px;
    font-weight: bolder;
  }
  /*****************第一层弹窗内容*****************/
  /deep/ .box > .el-dialog > .el-dialog__body{
    padding: 0 0 0 10px ;
    min-height: 50px;
    line-height: 30px;
    margin-top: 20px;
    margin-bottom: 20px;
  }
  /deep/ .box > .el-dialog > .el-dialog__body > .el-form > .el-form-item{
    margin-bottom: 0;
  }
  /deep/ .box > .el-dialog > .el-dialog__body > .el-form > .el-form-item > .el-form-item__label{
    color: #69727E;
    font-weight: normal;
  }
  /deep/ .box > .el-dialog > .el-dialog__body > .el-form > .el-form-item > .el-form-item__content > .el-input > .el-input__inner{
    width: 610px;
    height: 30px;
  }

</style>
